﻿using System;
using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Solution.Entity.Entitys;
using Solution.Repository.Interfaces;
using Solution.Repository.Interfaces.Base;

namespace Solution.Services.User
{
    public class UserServices : IUserServices
    {
        private readonly ISysUserRepository _userRepository;

        public UserServices(ISysUserRepository useRepositoryBase)
        {
            _userRepository = useRepositoryBase;
        }

        public SysUser Add()
        {
            var sysUser = new SysUser() {
                AddedTime = DateTime.Now,
                Enabled = false,
                Id = new Guid(),
                ModifiedTime = DateTime.Now,
                Name = "1"
            };

            return _userRepository.Insert(sysUser);
        }

        public SysUser Get(string id)
        {
            //var c = new SysUser() { Id = new Guid("E0DCD14C-1A21-45B1-9869-08D65538763A") };
            return _userRepository.Get(new Guid("E0DCD14C-1A21-45B1-9869-08D65538763A"));
        }

        public dynamic GetPage(int startPage, int pageSize, out int rowCount, Expression<Func<SysUser, bool>> predicate, Expression<Func<SysUser, dynamic>> order, bool isAcs)
        {
            return _userRepository.LoadPageList(startPage, pageSize, out rowCount, predicate, order, isAcs);
        }
    }
}